<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<style> 
#apply_form input { width:15em; padding:4px; border:1px solid #CCC; }
#apply_form input:focus { border-color:#426DC9; }
#apply_form .form-error { background:#FFFBFC; border-color:#F00 !important; }
</style>
<form id="apply_form" action="tuifei_addOrderRefund.shtml" method="post">
	<table border="0" cellpadding="0" cellspacing="0" width="100%" class="mytable">
		<tr>
			<th class="left">订单编号</th>
			<td class="border-top"><input name="refund.orderNo" style="border: solid 0px" value="${order.systemSn}"></td>
		</tr>
		<tr>
			<th class="left">订单总额</th>
			<td>￥<label id="total"><fmt:formatNumber value="${order.orderTotal}" pattern="0.00" /></label>
			</td>
		</tr>
		<tr>
			<th class="left">退款类型</th>
			<td>
				<input name="refundType" value="A" type="radio" id="all" /><label for="all">全额</label>
				<input name="refundType" value="B" type="radio" id="part" /><label for="part">部分</label>
			</td>
		</tr>
		<tr>
			<th class="left">退款金额</th>
			<td>
				<input value="" name="refund.amount" id="amount" />
			</td>
		</tr>
		<tr>
			<th class="left">退款备注</th>
			<td>
				<textarea rows="5" cols="50%" style="overflow: hidden;" name="refund.remarks" id="remarks"></textarea>
			</td>
		</tr>
	</table>
	<input name="refund.member" value="${order.memberNum}" /><br/>
</form>
<script type="text/dialog">
api = this,
form = $('#apply_form'),
amount = $('#amount'),
orderTotal = $('#total'),
refundType = $('input[name="refundType"]'),
remarks = $('#remarks');
api.title('退款申请').button(
{
	name:'确定',
	focus:true,
	callback:function(){
		if($.trim(refundType.val())==''){art.dialog.tips('请选择退款类型！',2);return false;}
		if($.trim(amount.val())==''){art.dialog.tips('请填写需退款的金额！',2);amount.focus();return false;}
		else if(parseFloat($.trim(amount.val()))>parseFloat(orderTotal.text())){
			art.dialog.tips('退款金额不能大于订单支付金额:'+orderTotal.text(),2);amount.select();return false;
		}
		else{
			if(/^[0-9]+([.]{1}[0-9]{0,2}){0,1}$/.test(amount.val())==false){
				art.dialog.tips('退款金额输入错误！',2);amount.select();return false;
			}
		}
		if($.trim(remarks.text())==''){art.dialog.tips('请填写备注信息',2);remarks.focus();return false;}
		var options = {
			url:form.attr('action'),
			type:'POST',
			cache:false,
			success:function(result){
				if(result=='T'){
					result = "退款申请成功";
				}else{
					result =  "退款申请失败："+result;
				}
				art.dialog({lock: true,	title : '系统提示',
							content : result + '，2秒后关闭……',
							time : 2,
							close : function() {closeAllDialog();}
							})
			}
		};
		form.ajaxSubmit(options);
		closeAllDialog();
		art.dialog({
					title:'系统提示',
					id:'system_warn',
					content:'系统正在处理中……',
					lock:true
				});
		return false;
	}
},
{name:'取消'});
refundType.click(function(){
	var refundTypeVal=$("input[name='refundType']:checked").val();
	if(refundTypeVal=='A'){amount.val(orderTotal.text());}
	else{amount.val('');}
});
</script>